package com.system.arrangement.service;

import com.system.arrangement.been.RegistrationPool;
import com.system.arrangement.dto.ArrangementDTO;

import java.util.ArrayList;
import java.util.List;

public class Subject {

    private List<Observer> observers
            = new ArrayList<Observer>();
    private ArrangementDTO arrangementDTO;

    public ArrangementDTO getArrangementDTO() {
        return arrangementDTO;
    }

    public RegistrationPool setArrangementDTO(ArrangementDTO arrangementDTO) {
        this.arrangementDTO = arrangementDTO;
        return notifyAllObservers();
    }

    public void attach(Observer observer){
        observers.add(observer);
    }

    public RegistrationPool notifyAllObservers(){
        for (Observer observer : observers) {
            return observer.update();
        }
        return null;
    }
}